package com.corpgovernment.organization.controller;

import com.corpgovernment.api.operatelog.chooseconstant.ChooseBusinesstype;
import com.corpgovernment.api.organization.model.org.response.GetOrgInfoResponseOld;
import com.corpgovernment.api.organization.model.switchinfo.GetPayConfigRequest;
import com.corpgovernment.api.organization.model.switchinfo.PayConfigRequest;
import com.corpgovernment.common.base.JSONResult;
import com.corpgovernment.common.operatelog.OperateLog;
import com.corpgovernment.organization.service.ISwitchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("payConfig")
public class PayConfigController {
    @Autowired
    private ISwitchService switchService;

    /**
     * 保存
     *
     * @param request
     * @return
     */
    @OperateLog(ChooseBusinesstype.PAYCONFIG)
    @RequestMapping(value = "/list/saveConfig")
    public JSONResult saveConfigInfo(@RequestBody @Valid PayConfigRequest request) {
        switchService.savePayConfigInfo(request);
        return JSONResult.ok();
    }

    /**
     * 查询配置
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/list/config")
    public JSONResult<List<GetOrgInfoResponseOld.OrgPayType>> getConfigInfo(@RequestBody @Valid  GetPayConfigRequest request) {
        return  JSONResult.success(switchService.getPayConfigInfo(request));
    }

}
